//app.js
App({
    netWorkData:{
        result: { code: -1, msg: '发起请求失败' }
    },
    onLaunch: function () {
    },
    gohome: function () {
        wx.switchTab({
            url: '/pages/index/index'
        })
        // wx.switchTab({
        //     url: '/pages/workbench/workbench'
        // })
        // wx.navigateTo({
        //     url: "/pages/area-manage/area-manage"
        // })
        // wx.navigateTo({
        //     url: '/pages/area-add/area-add'
        // })
    },
    //错误统一处理
    requestEro(success, msg) {
      if (msg =="未查询到openid绑定信息"){
        wx.reLaunch({
          url: '/pages/login/login'
        })
      }else{
       
        switch (success) {
            //成功
            case 1:
                return true;
            //失败
            case 0:
                wx.showModal({
                    content: msg,
                    showCancel: false,
                    success: function (res) {
                        if (res.confirm) {

                        }
                    }
                })
                return false;
            //token失效等token错误
            case -1:
                wx.showModal({
                    content: msg,
                    showCancel: false,
                    success: function (res) {
                        if (res.confirm) {
                            wx.reLaunch({
                                url: '/pages/login/login'
                            })
                        }
                    }
                })
                return false;
            //添加用户时，用户已存在
            case -2:
                wx.showModal({
                    content: msg,
                    showCancel: false,
                })
                return false;
            //默认密码需要重置
            case -3:
                wx.showModal({
                    content: msg,
                    showCancel: false,
                    success: function (res) {
                        if (res.confirm) {
                            wx.navigateTo({
                                url: '/pages/reset-password/reset-password?isLogin=0'
                            })
                        }
                    }
                })
                return false;
        }

      }

    },
    globalData: {
        userInfo: null,
        warningBool:true,
        needTryagain: false,
        APIURL: 'https://api2.legomalls.com',
        token: wx.getStorageSync('token'),
        aMapKey:'6841297aedc70f5ad7faabbcba445527',
        qqmapkey:'IGJBZ-FZL33-LZA3R-3E6T4-6SEJO-RAF7Q',
        areaList:wx.getStorageSync('areaList')
        // token: 'YLjAiZIJh6thK7FjpP/n+Rjck8JldTR5bPNyYoVhJDrU6ZKTGGVKlIWGtwPc9af0c511K+H6dIOf9pB9f9V4rEOpbkUsGkaQSvyrNnvBe1jSs7nDBsLvLaBdcIFuzw9f7y87H43D64qF7JZ3UPXnlMFFMwUaZ0EMFovD3xE+3VA=',
    }
})